#ifndef DRAGGABLE_TEXT_EDIT_H
#define DRAGGABLE_TEXT_EDIT_H

#include <QTextEdit>
#include <QWidget>
#include <QPoint>

class DraggableTextEdit : public QTextEdit
{
Q_OBJECT
public:
    explicit DraggableTextEdit(QWidget *parent = nullptr);

    void setOriginalParent(QWidget *parent, const QPoint &pos);
    void returnToOriginalPosition();
    void detachFromParent();

protected:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void contextMenuEvent(QContextMenuEvent *event) override;

private:
    bool isDragging;
    QPoint dragStartPosition;
    QWidget *originalParent;
    QPoint originalPosition;
    bool isDetached;
};

#endif // DRAGGABLE_TEXT_EDIT_H
